
/*
 * ------------------- CHANGE LOG -----------------------------------
 * DATE             MOD BY              DESCRIPTION
 * 01/30/11         Pia                 Created class
 *
 *
 */

package post;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;

public class Customer {
    private String name;
    private ArrayList<Item> items = new ArrayList<Item>();
    private Payment pay;

    public Customer() throws FileNotFoundException, IOException
    {
        setTransaction();   //put together list of items to purchase
    }//end constructor

    public void setTransaction() throws FileNotFoundException, IOException
    {
        TransactionReader reader = new TransactionReader("Store//transactions.txt");
        //name = reader.getName();    //retrieve customers name from file
        while( reader.hasMoreTrans() )
        {
            Item tempItem = reader.getNextItem();
            if( tempItem != null )  //if more items need to be added
            {
                items.add(tempItem); //add next item to list
            }
            else
            {
                pay = reader.getPayment();  //retrieve payment from file
                break;
            }
        }
        
    }
    /*
     * @return 0 on success
     */
    public Payment getPayment( ){
        return pay;
    }

    public String getName()
    {
        return name;
    }

    public ArrayList<Item> getList()
    {
        return items;
    }
}//end Customer class